package com.tools.cleanmaster.ui.view;

import android.content.Context;
import android.content.Intent;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.hm.base.android.ui.view.CommonInfoView;
import com.tools.ad.util.GARecordUtils;
import com.tools.cleanmaster.CleanApplication;
import com.tools.cleanmaster.CleanGAConstant;
import com.tools.cleanmaster.R;
import com.tools.cleanmaster.manager.AutoCleanManager;
import com.tools.cleanmaster.ui.activity.AutoCleanSettingActivity;


/**
 * Created by xuyang on 16/7/12.
 */
public class MainPageTipView extends CommonInfoView<CleanApplication> {

    private static final String TAG = "MainPageTipView";

    private Context mCtx;
    private TextView mTipTv;
    private ImageView mTipIcon;
    private ImageView mRightArrow;

    public MainPageTipView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public MainPageTipView(Context context) {
        super(context);
        init(context);
    }

    public MainPageTipView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context);
    }

    private void init(Context context) {
        mCtx = context;
        addView(R.layout.main_page_tip_view);

        setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                GARecordUtils.report(imContext, CleanGAConstant.C_FUNC, CleanGAConstant.A_CLICK, CleanGAConstant.L_HOME_CLEAN_BAR);

                Intent intent = new Intent(getContext(), AutoCleanSettingActivity.class);
                intent.putExtra(AutoCleanSettingActivity.FROM_EXTRA, AutoCleanManager.FROM_MENU);
                getContext().startActivity(intent);
            }
        });
    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        initView();
    }

    private void initView() {
        mTipTv = findViewById(R.id.tip_tv);
        mTipIcon = findViewById(R.id.tip_icon);
        mRightArrow = findViewById(R.id.right_arrow);

        mTipTv.setText(R.string.main_page_tip_guide_auto_clean);
        mTipTv.setTextColor(getResources().getColor(R.color.hot_warning));
        mTipIcon.setImageResource(R.drawable.main_page_tip_icon_warn);
        mRightArrow.setImageResource(R.drawable.arrow_right_orange);
        mRightArrow.setVisibility(VISIBLE);
    }
}
